package org.example.orders.controller;

import org.example.orders.config.MyPattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@RestController
@RequestMapping("hello")
public class HelloController {

   /* @Value("${pattern}")
    private String pattern;*/
    @Autowired
    private MyPattern myPattern;
    @GetMapping("time")
    public String getTime(){

        LocalDateTime now = LocalDateTime.now();

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(myPattern.getPattern());

        String format = now.format(formatter);

        return format;
    }

}
